import React, { useRef, useEffect, forwardRef } from 'react'
import { useGLTF, useAnimations } from '@react-three/drei'

const Room = forwardRef((props, ref) => {
  const { nodes, materials, animations } = useGLTF('/models/room.glb')
  const { actions } = useAnimations(animations, ref)
  useEffect(() => {
    for (const k in actions) {
      actions[k].play()
    }
  }, [actions]);
  return (
    <group visible={true} ref={ref} scale={1} dispose={null} position={0} >
      <group name="Scene">
        <group name="Area" position={[2.029657, 17.364758, -22.151518]} rotation={[1.994505, -0.743089, 0.216681]} scale={-1.144751} />
        <group name="Plane006" position={[0.006848, 7.917203, -8.350737]} rotation={[0, 0.269173, -Math.PI]} scale={1.069295}>
          <mesh name="Plane005_1" geometry={nodes.Plane005_1.geometry} material={materials.PaletteMaterial001} />
          <mesh name="Plane005_2" geometry={nodes.Plane005_2.geometry} material={materials.PaletteMaterial002} />
          <mesh name="Plane005_3" geometry={nodes.Plane005_3.geometry} material={materials.PaletteMaterial003} />
          <mesh name="Plane005_4" geometry={nodes.Plane005_4.geometry} material={materials.PaletteMaterial002} />
          <mesh name="Plane005_5" geometry={nodes.Plane005_5.geometry} material={materials.PaletteMaterial002} />
          <mesh name="Circle004" geometry={nodes.Circle004.geometry} material={materials.PaletteMaterial001} position={[0.054973, 2.604245, -0.087101]} rotation={[0, 0, Math.PI]} scale={1.237942} />
        </group>
        <mesh name="Cylinder001" geometry={nodes.Cylinder001.geometry} material={materials.PaletteMaterial001} position={[-4.372463, 4.74803, 5.827085]} scale={0.087951} />
        <mesh name="Cylinder002" geometry={nodes.Cylinder002.geometry} material={materials.PaletteMaterial002} position={[7.798685, 6.066274, 7.826903]} scale={1.321469} />
        {/* <mesh name="Plane005" geometry={nodes.Plane005.geometry} material={materials.PaletteMaterial003} position={[-0.042476, 1.458665, -0.002921]} scale={13.647086} /> */}
        <mesh name="Cylinder003" geometry={nodes.Cylinder003.geometry} material={materials.PaletteMaterial002} position={[-1.834956, 7.20728, -7.592279]} rotation={[2.104113, -0.415158, 1.005689]} scale={0} />
        <mesh name="Circle010" geometry={nodes.Circle010.geometry} material={materials.screen} position={[-0.014868, 10.242388, -34.358234]} rotation={[Math.PI / 2, 0, 0]} scale={6.673271} />
      </group>
    </group>
  )
})

useGLTF.preload('/models/room.glb')

export default Room;
